fun main(args: Array<String>) {
    val l1 = listOf<Int>(8, 4, 2, 9, 6, 3, 5, 7, 1)
    //          8
    //      4       9
    //   2     6
    // 1   3  5   7

    val b1 = BinarySearchTree<Int>()
    for (i in l1) {
        b1.add(i)
    }

    b1.levelOrder()
    println()

    b1.deleteElement(4)
    b1.levelOrder()
    println()
}

// 多种方式遍历二分搜索树
fun <T: Comparable<T>> traversal(bts: BinarySearchTree<T>) {
    bts.preOrder()
    println()
    bts.preOrderNoRecursion()
    println()
    bts.inOrder()
    println()
    bts.postOrder()
    println()
    bts.levelOrder()
    println()
}